package com.ibm.simpleserver;

import java.util.Vector;

public class Queue {
	private Vector<Runnable> theQue;

	public Queue(int initialSize, int growthFactor) {
		theQue = new Vector<Runnable>(initialSize, growthFactor);
	}

	public synchronized void add(Runnable runner) {
		theQue.add(runner);
		notify();
	}

	public synchronized Runnable next() {
		while (theQue.isEmpty()) {
			try {
				wait();
			} catch (InterruptedException ie) {
				System.out.println("Could not wait()");
				ie.printStackTrace(System.out);
			}
		}
		Runnable runner = (Runnable) theQue.remove(0);
		return runner;
	}

}
